package com.duyutian.zhanglong.p1启动一个服务;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * netty初始化器，channel 注册之后，会执行里面相应的初始化方法
 */
public class TestInitializer extends ChannelInitializer<SocketChannel> {


    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //添加解码器
        pipeline.addLast("httpServerCodec",new HttpServerCodec());
        //添加自定义的助手类
        pipeline.addLast("testHttpServerHandler",new TestHttpServerHandler());

    }
}
